package io;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: wenjingyuan
 * @Date: 2023/05/29/20:44
 * @Description:
 */
public class OutputStreamDemo4 {
    public static void main(String[] args) throws IOException {
        File file=new File("mytest.txt");
        if(!file.exists()) file.createNewFile();
        try(PrintWriter printWriter=new PrintWriter(file)){
            printWriter.println("这是第一行数据");
            printWriter.print("这是第二行数据");
            printWriter.printf("我叫：%s，今年：%d，至今未婚",
            "张三",18);
            printWriter.flush();
        }
    }
}
